<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/
if ($_GET[newstype]!='read') 
{
if ($_GET[type]=='1')
{
$newstype='新闻';
$keynews='news_new';
}elseif($_GET[type]=='2')
{
$newstype='图片新闻';
$keynews='news_pic_new';
}elseif($_GET[type]=='3')
{
$newstype='公告';
$keynews='news_cement';
}elseif($_GET[type]=='4')
{
$newstype='通知';
$keynews='news_notice';
}elseif($_GET[type]=='5')
{
$newstype='大事记';
$keynews='news_chronicle';
}elseif($_GET[type]=='6')
{
$newstype='电子期刊';
$keynews='news_periodical';
}

get_config_keytable($keynews);
}
empty($do) && $do = 'list';
if ($do == 'list') {
	//列表信息 
	$wheresql = '';
	$page = max(1, getGP('page','G','int'));
	$pagesize = 20;
	$offset = ($page - 1) * $pagesize;
	$type = getGP('type','G');
	$url = 'admin.php?ac=index&fileurl=news&type='.$type.'&muid='.$_GET[muid].'';
	if ($keyword = getGP('keyword','G')) {
		$wheresql .= " AND subject LIKE '%$keyword%'";
		$url .= '&keyword='.rawurlencode($keyword);
	}
	$vstartdate = getGP('vstartdate','G');
	$venddate = getGP('venddate','G');
	if ($vstartdate!='' && $venddate!='') {
	$wheresql .= " AND (date>='".$vstartdate."' and date<='".$venddate."')";
	$url .= '&vstartdate='.$vstartdate.'&venddate='.$venddate;
	}
	//权限
	if(!is_superadmin()){
	$wheresql .= " AND (receive like'%".GET_INC_USER_NAME($_USER->id)."%' or receive='0' or uid='".$_USER->id."')";
	}
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."news WHERE 1 $wheresql and type=".$type."");
     $sql = "SELECT * FROM ".DB_TABLEPRE."news WHERE 1 $wheresql and type=".$type." ORDER BY id desc LIMIT $offset, $pagesize";
	$result = $db->fetch_all($sql);

	include_once('template/index.php');

} elseif ($do == '删 除') {

if ($_GET[type]=='1')
{
$newstype='新闻';
$keynews='news_new_delete';
}elseif($_GET[type]=='2')
{
$newstype='图片新闻';
$keynews='news_pic_new_delete';
}elseif($_GET[type]=='3')
{
$newstype='公告';
$keynews='news_cement_delete';
}elseif($_GET[type]=='4')
{
$newstype='通知';
$keynews='news_notice_delete';
}elseif($_GET[type]=='5')
{
$newstype='大事记';
$keynews='news_chronicle_delete';
}elseif($_GET[type]=='6')
{
$newstype='电子期刊';
$keynews='news_periodical_delete';
}

get_config_keytable($keynews);


	$idarr = getGP('id','P','array');
	foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."news WHERE id = '$id'");
	$db->query("DELETE FROM ".DB_TABLEPRE."news_read WHERE newsid = '$id'");
	$content=$id;
	$title='删除'.$newstype.'信息';
	get_oa_log_dbadd($id,$content,$title,13,$_USER->id);
	}
	goto_page('admin.php?ac=index&fileurl=news&type='.getGP('type','P').'&message=1&muid='.getGP('muid','P').'');

} 
elseif ($do == 'htcdelete') {
if ($_GET[type]=='1')
{
$newstype='新闻';
$keynews='news_new_delete';
}elseif($_GET[type]=='2')
{
$newstype='图片新闻';
$keynews='news_pic_new_delete';
}elseif($_GET[type]=='3')
{
$newstype='公告';
$keynews='news_cement_delete';
}elseif($_GET[type]=='4')
{
$newstype='通知';
$keynews='news_notice_delete';
}elseif($_GET[type]=='5')
{
$newstype='大事记';
$keynews='news_chronicle_delete';
}elseif($_GET[type]=='6')
{
$newstype='电子期刊';
$keynews='news_periodical_delete';
}

get_config_keytable($keynews);
	$idarr = getGP('id','G');
	//foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."news WHERE id = '$idarr'");
	$db->query("DELETE FROM ".DB_TABLEPRE."news_read WHERE newsid = '$idarr'");
	$content=$idarr;
	$title='删除'.$newstype.'信息';
	get_oa_log_dbadd($idarr,$content,$title,13,$_USER->id);
	//}
	goto_page('admin.php?ac=index&fileurl=news&type='.getGP('type','G').'&message=1&muid='.getGP('muid','G').'');

} 

//读部门

?>